// Package sysin
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sysin

import (
	"context"
	"github.com/gogf/gf/v2/encoding/gjson"
	"hotgo/internal/consts"
	"hotgo/internal/model/entity"
	"hotgo/internal/model/input/form"
	"hotgo/utility/validate"

	"github.com/gogf/gf/v2/errors/gerror"
)

// ProductNewUpdateFields 修改新人有礼活动字段过滤
type ProductNewUpdateFields struct {
	ProductId int64   `json:"productId" dc:"商品ID"`
	NewPrice  float64 `json:"newPrice"  dc:"新人价格"`
	Status    int     `json:"status"    dc:"状态：1-上架、2-下架"`
}

// ProductNewInsertFields 新增新人有礼活动字段过滤
type ProductNewInsertFields struct {
	ProductId int64   `json:"productId" dc:"商品ID"`
	NewPrice  float64 `json:"newPrice"  dc:"新人价格"`
	Status    int     `json:"status"    dc:"状态：1-上架、2-下架"`
}

// ProductNewEditInp 修改/新增新人有礼活动
type ProductNewEditInp struct {
	entity.ProductNew
}

func (in *ProductNewEditInp) Filter(ctx context.Context) (err error) {

	return
}

type ProductNewEditModel struct{}

// ProductNewViewInp 获取指定新人有礼活动信息
type ProductNewViewInp struct {
	Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"`
}

func (in *ProductNewViewInp) Filter(ctx context.Context) (err error) {
	return
}

type ProductNewViewModel struct {
	entity.ProductNew
}

// ProductNewListInp 获取新人有礼活动列表
type ProductNewListInp struct {
	form.PageReq
	ProductName string `json:"productName" dc:"商品名称"`
}

func (in *ProductNewListInp) Filter(ctx context.Context) (err error) {
	return
}

type ProductNewListModel struct {
	Id               int64       `json:"id"               dc:"ID"`
	NewPrice         float64     `json:"newPrice"         dc:"新人价格"`
	Status           int         `json:"status"           dc:"状态：1-上架、2-下架"`
	SellCount        int         `json:"sellCount"        dc:"销量"`
	ProductName      string      `json:"productName"      dc:"商品名称"`
	ProductMainImage *gjson.Json `json:"productMainImage" dc:"商品主图"`
}

// ProductNewStatusInp 更新新人有礼活动状态
type ProductNewStatusInp struct {
	Id     int64 `json:"id" v:"required#ID不能为空" dc:"ID"`
	Status int   `json:"status" dc:"状态"`
}

func (in *ProductNewStatusInp) Filter(ctx context.Context) (err error) {
	if in.Id <= 0 {
		err = gerror.New("ID不能为空")
		return
	}

	if in.Status <= 0 {
		err = gerror.New("状态不能为空")
		return
	}

	if !validate.InSlice(consts.StatusSlice, in.Status) {
		err = gerror.New("状态不正确")
		return
	}
	return
}

type ProductNewStatusModel struct{}
